package com.study.java8.char08;

// reuse/Cartoon.java
// (c)2017 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
// Constructor calls during inheritance

class Art {
    {
        System.out.println("Art 代码块");
    }

    static {
        System.out.println(" Art 静态代码块");
    }

    Art() {
        System.out.println("Art constructor");
    }
}

class Drawing extends Art {
    {
        System.out.println("Drawing 代码块");
    }

    static {
        System.out.println(" Drawing 静态代码块");
    }

    Drawing() {
        System.out.println("Drawing constructor");
    }
}

public class Cartoon extends Drawing {
    public Cartoon() {
        System.out.println("Cartoon constructor");
    }

    public static void main(String[] args) {
        Cartoon x = new Cartoon();
    }
}
/* Output:|先执行静态代码块 在执行 代码块 在执行 构造函数|
 Art 静态代码块
 Drawing 静态代码块
Art 代码块
Art constructor
Drawing 代码块
Drawing constructor
Cartoon constructor
*/
